﻿using System;

namespace Borg.Framework
{
    public class ReplaceAction : Action
    {
        private readonly PlugAction _plugAction;
        private readonly UnplugAction _unplugAction;

        public ReplaceAction(SlotInfo slot, QualifyDelegate unplug, QualifyDelegate plug)
            : base(slot, null)
        {
            _unplugAction = new UnplugAction(slot, unplug);
            _plugAction = new PlugAction(slot, plug);
        }

        public ReplaceAction(SlotInfo slot, string param, object valueUnplug, object valuePlug)
            : base(slot, null)
        {
            _unplugAction = new UnplugAction(slot, param, valueUnplug);
            _plugAction = new PlugAction(slot, param, valuePlug);
        }

        public override void Do(object s, EventArgs args)
        {
            _unplugAction.Do(s, args);
            _plugAction.Do(s, args);
        }
    }
}

